       IDENTIFICATION DIVISION.
       PROGRAM-ID. SecuenciarArchivoAsignaciones.
       AUTHOR. Grupo 5. 2do cuatrimestre 2011.

       ENVIRONMENT DIVISION.
         INPUT-OUTPUT SECTION.
           FILE-CONTROL.
             SELECT SEQ-ARCH ASSIGN TO "ASIGNACIONES.SEQ"
                 ORGANIZATION IS LINE SEQUENTIAL.

             SELECT ASIG-ARCH ASSIGN TO "ASIGNACIONES.IDX"
                 ORGANIZATION IS INDEXED
                 ACCESS MODE IS SEQUENTIAL
                 RECORD KEY IS ASIG-CLAVE
                 FILE STATUS IS ASIG-STATUS.

       DATA DIVISION.
         FILE SECTION.
           COPY "Asignaciones-FD.cbl".

           FD SEQ-ARCH.
           01 SEQ-REG.
             88 SEQ-EOF                 VALUE HIGH-VALUES.
             02 SEQ-FIELDS              PIC X(32).

         WORKING-STORAGE SECTION.
           01 ASIG-STATUS               PIC X(02).

       PROCEDURE DIVISION.
         OPEN OUTPUT SEQ-ARCH
         OPEN INPUT ASIG-ARCH

         MOVE SPACES TO ASIG-CLAVE
         START ASIG-ARCH
             KEY IS GREATER THAN ASIG-CLAVE
             INVALID KEY DISPLAY "CLAVE INVALIDA:- ", ASIG-STATUS
         END-START
         
         READ ASIG-ARCH NEXT RECORD
             AT END SET ASIG-EOF TO TRUE
         END-READ.
         
         PERFORM UNTIL ASIG-EOF
             MOVE ASIG-REG TO SEQ-REG
             WRITE SEQ-REG

             READ ASIG-ARCH NEXT RECORD
                 AT END SET ASIG-EOF TO TRUE
             END-READ
         END-PERFORM
          
         CLOSE SEQ-ARCH
         CLOSE ASIG-ARCH

         STOP RUN
         .
